check if localstorage key exists

105

check if localstorage key exists -

if (localStorage.getItem("username") === null) {
  //...
}

check if item exists in localstorage javascript -

//If the given key does not exist in the list associated with the object then this method must return null.

if (localStorage.getItem("infiniteScrollEnabled") === null) {
  //...
}

Comments

Submit
0 Comments